<?php
class My_View_Helper_PhoneElement extends Zend_View_Helper_FormElement
{
    protected $html = '';

    public function phoneElement($name, $value = null, $attribs = null) {
        $areanum = $geonum = $localnum = $extnum = '';

        $helper = new Zend_View_Helper_FormText();
        $helper->setView($this->view);

        if (is_array($value)) {
            $areanum = isset($value['areanum']) ? $value['areanum'] : '';
            $geonum = isset($value['geonum']) ? $value['geonum'] : '';
            $localnum = isset($value['localnum']) ? $value['localnum'] : '';
            $extnum = isset($value['extnum']) ? $value['extnum'] : '';
        }

        $this->html .= '+' . $helper->formText($name . '[areanum]', $areanum, array('maxlength' => '2', 'size' => '2'));
        $this->html .= ' (' . $helper->formText($name . '[geonum]', $geonum, array('maxlength' => '4', 'size' => '4'));
        $this->html .= ') ' . $helper->formText($name . '[localnum]', $localnum, array('maxlength' => '8', 'size' => '8'));
        $this->html .= ' (доп.' . $helper->formText($name . '[extnum]', $extnum, array('maxlength' => '4', 'size' => '4')) . ')';

        return $this->html;
    }
}
